package com.gangquan360.smartadmin.module.customer.controller;

import com.gangquan360.smartadmin.common.anno.NoValidPrivilege;
import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.constant.SwaggerTagConst;
import com.gangquan360.smartadmin.module.customer.domain.dto.CustomerDTO;
import com.gangquan360.smartadmin.module.customer.domain.dto.CustomerQueryDTO;
import com.gangquan360.smartadmin.module.customer.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import javax.validation.Valid;

/**
 * [ 客户表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-08 21:09:45
 * @since JDK1.8
 */
@RestController
@Api(tags = {SwaggerTagConst.Group2.CUSTOMER_MANGER})
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @ApiOperation(value = "分页查询客户表",notes = "@author wiggin")
    @PostMapping("/customer/page/query")
    public ResponseDTO<PageResultDTO<CustomerDTO>> queryByPage(@RequestBody CustomerQueryDTO queryDTO) {
        return customerService.queryByPage(queryDTO);
    }
    
    @ApiOperation("查询客户列表")
    @NoValidPrivilege
    @GetMapping("/customer/list")
    public ResponseDTO<List<CustomerDTO>> queryList() {
    	return customerService.queryList();
    }
    

    @ApiOperation(value = "添加客户表",notes = "@author wiggin")
    @PostMapping("/customer/add")
    public ResponseDTO<String> add(@RequestBody @Valid CustomerDTO addTO){
        return customerService.add(addTO);
    }

    @ApiOperation(value="修改客户表",notes = "@author wiggin")
    @PostMapping("/customer/update")
    public ResponseDTO<String> update(@RequestBody @Valid CustomerDTO updateDTO){
        return customerService.update(updateDTO);
    }


    @ApiOperation(value="删除客户表",notes = "@author wiggin")
    @GetMapping("/customer/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return customerService.delete(id);
    }


    @ApiOperation(value="详情客户表",notes = "@author wiggin")
    @GetMapping("/customer/detail/{id}")
    public ResponseDTO<CustomerDTO> detail(@PathVariable("id") Long id){
        return customerService.detail(id);
    }
}
